#include "Logger.hpp"
#include <time.h>

using namespace klasPhysics;



ofstream Logger::m_File;

// Starts up the logger and automatically appends when the program ran
bool Logger::Init(string filePath)
{
	m_File.open(filePath.c_str(), ios::out | ios::app); // Open the file in output mode and start at the end of the file

	// if we failed to open the file, then return false
	if(!m_File.is_open())
		return false;

	// create a new section
	m_File << "\n\n\n";

	// get date and time
	/*string dateTime;
	char date[9], time[9];
	strdate(date);
	strtime(time);
	string sDate = date;
	string sTime = time;

	// make it look better
	sDate.replace(2, 1, ".");
	sDate.replace(5, 1, ".");
	dateTime += sDate;
	dateTime += " at time ";
	sTime.replace(2, 1, "-");
	sTime.replace(5, 1, "-");
	dateTime += sTime;

	// add it to the file
	Log(dateTime);*/
	Log("--------------------------------------------------");

	return m_File.good();
}

// Close the logger
bool Logger::Shutdown()
{
	m_File.close();

	if(m_File.is_open())
		return false;

	return true;
}



